﻿{% extends 'cms/base.html' %}

{% block title %}
    学生信息查询
{% endblock %}
{% block page_header %}
    学生信息查询
{% endblock %}

{% block head %}

{% endblock %}

{% block content %}
<div class="row">
<div class="col-md-12">
    <!-- Advanced Tables -->
    <div class="panel panel-default">
        <div class="panel-heading">
             查询
        </div>
        <div class="panel-heading">
            {% include 'cms/student/student_selected.html' %}
        </div>


        <div class="panel-body">
            <div class="table-responsive">
                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                    <thead>
                        <tr>
                            <th>学号</th>
                            <th>姓名</th>
                            <th>性别</th>
                            <th>班级</th>
                            <th>课程</th>
                            {% if flag %}
                                <th>成绩</th>
                            {% endif %}
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for result in results %}
                            <tr class="gradeX" data-id="{{ result[0] }}">
                            <td>{{ result[0]}}</td>
                            <td>{{ result[1] }}</td>
                            <td>{{ result[2] }}</td>
                            <td>{{ result[3] }}</td>
                            <td>{{ result[4] }}</td>
                            {% if flag %}
                                <td>{{ result[5] }}</td>
                            {% endif %}
                            <td>
                                <form action="{{ url_for('cms.editStudent') }}" style="float: left;margin-left:20%">
                                    <input style="display: none" value="{{ result[0] }}" name="Sno"/>
                                    <input id="edit" type="submit" class="btn btn-success btn-sm" value="编辑">
                                </form>
{#                                <a href="{{ url_for('cms.editStudent', Sno=result[0]) }}">编辑</a>#}
                                <form action="{{ url_for('cms.deleteStudent') }}" method="post" style="float: right; margin-right: 20%">
                                    <input style="display: none" name="Sno" value="{{ result[0] }}"/>
                                    <input  type="submit" value="删除" class="btn btn-danger btn-sm delete">
                                </form>

                            </td>
                        </tr>
                        {% endfor %}

                    </tbody>
                </table>
            </div>

        </div>
    </div>
    <!--End Advanced Tables -->
</div>
</div>
<!--

 /. ROW  -->


{% endblock %}
{% block js %}
    <script type="text/javascript">
    $(function () {
        $(".delete").click(function (event) {
             var self = $(this);
            var tr = self.parent().parent().parent();
            var SNO = tr.attr("data-id");
            console.log(SNO);
            event.preventDefault();
            zlalert.alertConfirm({
                'title':'确认删除吗？',
                'confirmCallback': function () {
                zlajax.post({
                    'url': '/cms/deleteStudent/',
                    'data': {
                        'SNO': SNO
                    },
                    'success': function (data) {
                        if(data['code'] == 200){
                            setTimeout(function(){
                                zlalert.alertSuccessToast('删除成功')
                            },200);
                            setTimeout(function(){
                                window.location.reload();
                            },1600);
                        }else {
                            zlalert.alertInfo(data['message']);
                        }
                    }
                })
                }
            });

        });
    })
    </script>
{% endblock %}